/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import org.junit.After
import org.junit.AfterClass
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import static org.junit.Assert.*
import inc.veluvana.weatherforecaster.PdfGenerator
import inc.veluvana.weatherforecaster.Order
import inc.veluvana.weatherforecaster.*

/**
 *
 * @author victor
 */
class testGenerarPdf {

    public testGenerarPdf() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }
    
    /** For printer for debug **/
    def printOrder(order) {
        /* print order content */
        order.getItems().each { k, v ->
            println "Type: ${k.cannonicalName} Unit Price: ${k.unitPrice} DeliveryTime: ${k.deliveryTime}\tAmount: ${v}"
        }
        // Calculate must be called before get Purchase price and delivery time
        println "\nPurchase Price: " + order.getPurchasePrice() + " DeliveryTime: " + order.getDeliveryTime() + "\n"
    }

    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
     @Test
     public void generatedPdf() {
        def order=new Order()
        order.setBuyerName("Victor Contreras")
        order.setAdressDelivery("Street 123 av Sim")
        order.setAmount(Hardwood.CHERRY, 100)
        order.setAmount(Hardwood.SAWDUST, 200)
        
        
        printOrder(order)
        
        def h = new Hardwood(7, 5.0, 2.5, "custom_hardwood")
        OrderLoader.addHardwood(h)
        
        // Print all available order loader
        println "Defined Hardwoods in OrderLoader"
        OrderLoader.getDefinedHardwoods().each {
            k, v ->
            println " - ${k}"
        }
        println ""
        
        def gen= new PdfGenerator()
        assert "Pdf was created successfully"==gen.principal(order)
    }
}
